(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=micmic
Title=labutaca.net
Description=labutaca.net+Google
Site=www.labutaca.net
Language=ES
Version=1.5
Requires=3.5.0
Comments= Author : micmic (micmic@dieznet.com) |BetaTester: Macoco (gracias)
License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
GetInfo=1
[Options]
***************************************************)
program labutacaImport;
var
MovieName: string;
const
Dominio = 'www.labutaca.net';
BaseURL1 = 'http://www.google.com/custom?hl=es&ie=ISO-8859-1&cof=&domains=';
BaseURL2 = '&q=';
BaseURL3 = '&btnG=B%FAsqueda+en+Google&sitesearch=';
function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
var
i: Integer;
begin
result := -1;
if StartAt < 0 then
StartAt := 0;
for i := StartAt to List.Count-1 do
if Pos(Pattern, List.GetString(i)) <> 0 then
begin
result := i;
Break;
end;
end;
function EliminaInicio(S: string; CR: string): string;
begin
result := S;
while Pos(CR, result) = 1 do
begin
Delete(result, 1, Length(CR));
end;
end;
function SustitucionReiterada(S: string; Buscado: string; Sustituto: string): string;
var
InicioPos: Integer;
Longitud: Integer;
TextoAntes: string;
TextoDespues : string;
begin
result := S;
Longitud := Length(Buscado);
InicioPos := Pos(Buscado, result);
while InicioPos > 0 do
begin
TextoAntes := copy(result, 1, InicioPos);
TextoDespues := copy(result, (InicioPos + Longitud), Length(result));
result := TextoAntes + TextoDespues;
InicioPos := Pos(Buscado, result);
end;
end;
function CadenaEntre(var S: string; StartTag: string; EndTag: string): string;
var
InicioPos: Integer;
S_Aux: string;
begin
S_Aux := S;
InicioPos := Pos(StartTag, S_Aux);
Delete(S_Aux, 1, InicioPos + Length(StartTag) - 1);
InicioPos := Pos(EndTag, S_Aux);
result := copy(S_Aux, 1, InicioPos - 1);
Delete(S_Aux, 1, InicioPos + 1);
end;
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
PosIni, PosFin: Integer;
Line, SubLine: string;
Title, DirURL: string;
txtTemp: string;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if Pos('No se encontró ninguna página', Page.Text) > 0 then
begin
ShowMessage('No se ha encontrado ningún artículo por título.');
end else
begin
PickTreeClear;
PickTreeAdd('Resultados de la búsqueda para "' + MovieName + '" (' + Dominio + ') por Google:', '');
Page.Text := StringReplace(Page.Text, '
', #13#10);
Page.Text := StringReplace(Page.Text, '
', #13#10 + '
'); // buscamos los resultados LineNr := 0; while LineNr < Page.Count do begin SubLine := Page.GetString(LineNr); txtTemp := '
'; PosFin := pos(txtTemp, SubLine); DirURL := Copy(SubLine, 1, PosFin - 1); DirURL := StringReplace(DirURL, '"', ''); SubLine := Copy(SubLine, PosFin + Length(txtTemp), Length(SubLine)); txtTemp := ''; PosFin := pos(txtTemp, SubLine); Title := Copy(SubLine, 1, PosFin - 1); HTMLRemoveTags(Title); //ShowMessage(Title + '-->' + DirURL); PickTreeAdd(Title, DirURL); end; LineNr := LineNr + 1; end; Page.Free; if PickTreeExec(Address) then AnalyzeMoviePage(Address); end; end; procedure AnalyzeMoviePage(Address: string); var MoviePage: TStringList; LineNr: Integer; posIni: Integer; LineImg: string; Line: string; valor: string; txttemp: string; begin Line := ''; LineImg := ''; SetField(fieldURL, Address); MoviePage := TStringList.Create; MoviePage.Text := GetPage(Address); LineNr := FindLine('